/**
 * API错误类
 * @extends Error
 */
class ApiError extends Error {
  /**
   * 创建API错误
   * @param {number} statusCode - HTTP状态码
   * @param {string} message - 错误消息
   * @param {boolean} [isOperational=true] - 是否为操作错误
   * @param {string} [stack=''] - 错误堆栈
   */
  constructor(statusCode, message, isOperational = true, stack = '') {
    super(message);
    this.statusCode = statusCode;
    this.isOperational = isOperational;
    if (stack) {
      this.stack = stack;
    } else {
      Error.captureStackTrace(this, this.constructor);
    }
  }
}

module.exports = ApiError; 